import 'package:chat/config/app_routes.dart';
import 'package:chat/controller/add_group_controller.dart';
import 'package:chat/controller/friend_chat_controller.dart';
import 'package:chat/controller/friend_detail_controller.dart';
import 'package:chat/controller/friend_list_controller.dart';
import 'package:chat/controller/group_chat_controller.dart';
import 'package:chat/controller/group_detail_controller..dart';
import 'package:chat/controller/group_list_controller.dart';
import 'package:chat/controller/group_manage_controller.dart';
import 'package:chat/controller/messageg_list_controller.dart';
import 'package:chat/generated/l10n.dart';
import 'package:chat/screen/tab_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart';

void main() async {
  Get.put(MessageListController());
  Get.put(FriendListController());
  Get.put(FriendDetailController());
  Get.put(FriendChatController());
  Get.put(GroupListController());
  Get.put(GroupDetailController());
  Get.put(GroupManageController());
  Get.put(GroupChatController());
  Get.put(AddGroupController());
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      home: TabScreen(),
      getPages: AppRoutes.routes,
      // routingCallback: (Routing? routing) {
      //   if (routing?.current == '/friendChatScreen') {
      //     WidgetsBinding.instance.addPostFrameCallback((_) {
      //       FriendChatController friendChatController = Get.find();
      //       friendChatController.scrollToBottom();
      //       debugPrint('滚动到底部');
      //     });
      //   }
      // },
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        fontFamily: 'Blod',
        scaffoldBackgroundColor: Colors.white,
        bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.white),
        iconTheme: const IconThemeData(color: Colors.black),
        dialogTheme: const DialogTheme(backgroundColor: Colors.white),
        appBarTheme: AppBarTheme(
          systemOverlayStyle: SystemUiOverlayStyle(
            statusBarColor: Colors.white, // 状态栏背景色
            statusBarIconBrightness: Brightness.dark, // 图标颜色（黑）
            statusBarBrightness: Brightness.light, // iOS状态栏文字亮色
          ),
        ),
      ),
      //supportedLocales: const [Locale('en', ''), Locale('pl', ''), Locale('zh', '')],
      locale: Get.deviceLocale ?? const Locale('zh'),
      fallbackLocale: const Locale('en'),
      localizationsDelegates: [
        S.delegate, // 自动生成的代理
        GlobalMaterialLocalizations.delegate, // Material组件国际化
        GlobalWidgetsLocalizations.delegate, // Widget基础功能（如文字方向）
      ],
      supportedLocales: S.delegate.supportedLocales,
      title: 'Chat App',
    );
  }
}
